<template>
  <div class="search">
    <Card>
      <Row>
        <Form ref="searchForm" inline :label-width="70" class="search-form">
          <FormItem label="托运单号" prop="orderNo">
            <Input
              type="text"
              v-model="searchForm.orderNo"
              placeholder="请输入托运单号"
              clearable
              style="width: 150px"
            />
          </FormItem>
          <FormItem label="选择日期">
            <DatePicker
              clearable
              type="daterange"
              placement="bottom-end"
              placeholder="请选择日期"
              style="width: 200px"
              v-model="date"
              @on-change="changeDate"
            ></DatePicker>
          </FormItem>
          <FormItem style="margin-left: -35px" class="br">
            <Button @click="handleSearch" type="primary" icon="ios-search"
              >搜索</Button
            >
            <Button @click="handleReset">重置</Button>
            <Button @click="getDataList" icon="md-refresh">刷新</Button>
            <!-- <Button @click="exportSelectData" icon="md-cloud-upload"
              >导出所选数据</Button
            > -->
          </FormItem>
        </Form>
      </Row>

      <Tabs v-model="consulaint" @on-click="ConsultingComplaints" type="card">
        <TabPane label="托运人" name="shipperName">
          <Row>
            <Table
              :loading="loading"
              border
              :columns="shipperColumns"
              :data="data"
              ref="table"
              @on-selection-change="shichangeSelect"
            ></Table>
          </Row>
          <Row type="flex" justify="end" class="page" style="margin-top: 2vh">
            <Page
              :current="searchForm.pageNumber"
              :total="total"
              :page-size="searchForm.pageSize"
              @on-change="changePage"
              @on-page-size-change="changePageSize"
              :page-size-opts="[10, 20, 50]"
              size="small"
              show-total
              show-elevator
              show-sizer
            ></Page>
          </Row>
        </TabPane>
        <TabPane label="实际承运人" name="actualCarrierName">
          <Row>
            <Table
              :loading="loading"
              border
              :columns="actualColumns"
              :data="data"
              ref="table"
              @on-selection-change="changeSelect"
            ></Table>
          </Row>
          <Row type="flex" justify="end" class="page" style="margin-top: 2vh">
            <Page
              :current="searchForm.pageNumber"
              :total="total"
              :page-size="searchForm.pageSize"
              @on-change="changePage"
              @on-page-size-change="changePageSize"
              :page-size-opts="[10, 20, 50]"
              size="small"
              show-total
              show-elevator
              show-sizer
            ></Page>
          </Row>
        </TabPane>
      </Tabs>
    </Card>
    <!-- 自定义导出数据 -->

    <Modal
      width="800"
      v-model="settlementModal"
      title="评论详情"
      @on-cancel="cancel"
    >
      <div>
        <div style="display: flex">
          <div class="box">
            托运单号:<span style="margin-left: 10px">
              {{ dataPict.orderNo }}</span
            >
          </div>
          <div class="box">
            货运单号:<span style="margin-left: 10px">
              {{ dataPict.orderNo }}</span
            >
          </div>
          <div class="box"></div>
        </div>
        <div style="display: flex; margin-top: 20px">
          <div class="box">
            评价人: <span style="margin-left: 10px"> {{ dataPict.ename }}</span>
          </div>
          <div class="box">
            被评价人:
            <span style="margin-left: 10px"> {{ dataPict.dname }}</span>
          </div>
          <div class="box"
           style="margin-left: 20px;">
            评价时间:
            <span style="margin-left: 10px"> {{ dataPict.createTime }}</span>
          </div>
        </div>

        <div style="display: flex; margin-top: 20px">
          <div class="box">
            运输效率
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.transportEfficiency"
            >
            </Rate>
          </div>

          <div class="box">
            运输安全
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.transportationSafety"
            >
            </Rate>
          </div>
          <div class="box"></div>
        </div>

        <div style="display: flex; margin-top: 20px">
          <div class="box">
            服务质量
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.serviceQuality"
            >
            </Rate>
          </div>
          <div class="box">
            客户满意度
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.customerSatisfaction"
            >
            </Rate>
          </div>
          <div class="box"></div>
        </div>
        <div style="width: 100%; height: 16px"></div>
      </div>
      <div slot="footer">
        <Button @click="settlementModal = false" type="primary">确定</Button>
      </div>
    </Modal>

    <Modal
      width="800"
      v-model="settlementModals"
      title="评论详情"
      @on-cancel="cancel"
    >
      <div>
        <div style="display: flex">
          <div class="box">
            托运单号:<span style="margin-left: 10px">
              {{ dataPict.orderNo }}</span
            >
          </div>
          <div class="box">
            货运单号:<span style="margin-left: 10px">
              {{ dataPict.orderNo }}</span
            >
          </div>
          <div class="box"></div>
        </div>
        <div style="display: flex; margin-top: 20px">
          <div class="box">
            评价人: <span style="margin-left: 10px"> {{ dataPict.ename }}</span>
          </div>
          <div class="box">
            被评价人:
            <span style="margin-left: 10px"> {{ dataPict.dname }}</span>
          </div>
          <div class="box">
            评价时间:
            <span style="margin-left: 10px"> {{ dataPict.createTime }}</span>
          </div>
        </div>

        <div style="display: flex; margin-top: 20px">
          <div class="box">
            货源靠谱
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.sourceGoods"
            >
            </Rate>
          </div>
          <div class="box">
            交通便利
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.traffic"
            >
            </Rate>
          </div>
          <div class="box"></div>
        </div>
        <div style="display: flex; margin-top: 20px">
          <div class="box">
            好装好卸
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.loadingUnloading"
            >
            </Rate>
          </div>

          <div class="box">
            结算及时
            <Rate
              style="margin-left: 10px"
              disabled
              allow-half
              v-model="dataPict.settlement"
            >
            </Rate>
          </div>
          <div class="box"></div>
        </div>
        <div style="width: 100%; height: 16px"></div>
      </div>

      <div slot="footer">
        <Button @click="settlementModals = false" type="primary">确定</Button>
      </div>
    </Modal>

    <!-- 自定义导出数据 -->
    <Modal
      v-model="shiperexportModalVisible"
      :title="shipexportTitle"
      :loading="loadingExport"
      @on-ok="shiexportCustomData"
    >
      <Form ref="exportForm" :label-width="100">
        <FormItem label="导出文件名">
          <Input v-model="shipfilename" />
        </FormItem>
        <FormItem label="自定义导出列">
          <CheckboxGroup v-model="shichooseColumns">
            <Checkbox
              v-for="(item, i) in shiexportColumns"
              :label="item.title"
              :key="i"
              :value="item.checked"
              :disabled="item.disabled"
            ></Checkbox>
          </CheckboxGroup>
        </FormItem>
        <FormItem label="备注">
          <Input
            v-model="exportRemarks"
            placeholder="备注"
            style="width: 300px"
          />
        </FormItem>
      </Form>
    </Modal>
    <!-- 自定义导出数据 -->
    <Modal
      v-model="exportModalVisible"
      :title="exportTitle"
      :loading="loadingExport"
      @on-ok="exportCustomData"
    >
      <Form ref="exportForm" :label-width="100">
        <FormItem label="导出文件名">
          <Input v-model="filename" />
        </FormItem>
        <FormItem label="自定义导出列">
          <CheckboxGroup v-model="chooseColumns">
            <Checkbox
              v-for="(item, i) in exportColumns"
              :label="item.title"
              :key="i"
              :value="item.checked"
              :disabled="item.disabled"
            ></Checkbox>
          </CheckboxGroup>
        </FormItem>
        <FormItem label="备注">
          <Input
            v-model="exportRemarks"
            placeholder="备注"
            style="width: 300px"
          />
        </FormItem>
      </Form>
    </Modal>
    <!-- 货主详情 -->
    <OwnerDetails
      @OwnerDetaiEnd="OwnerDetaiEnd"
      :OwnerDetailsId="OwnerDetailsId"
      :OwnerDetailsModalue="this.OwnerDetailsModalue"
    >
    </OwnerDetails>
 
    <!-- 车主 -->
    <NewOwnerDetails
      @newOwnerDetailsEnd="newOwnerDetailsEnd"
      :newOwnerDetailsId="newOwnerDetailsId"
      :newOwnerDetails="this.newOwnerDetails"
    >
    </NewOwnerDetails>
  </div>
</template>

<script>
// 根据你的实际请求api.js位置路径修改
import excel from "@/libs/excel";
import { addDownloadRecord } from "@/api/index";
import OwnerDetails from "@/views/componentsonn_source_goods/OwnerDetails";
import { getEvaluatePage } from "@/api/index";
import NewOwnerDetails from "@/views/componentsonn_source_goods/newOwnerDetails";
export default {
  name: "companyAanalyse",
  data() {
    return {
      newOwnerDetails: false, //车主弹框
      newOwnerDetailsId: "", //车主Id
      consulaint: "shipperName",
      OwnerDetailsId: "", //货主Id
      OwnerDetailsModalue: false, //货主详情弹框
      loading: false,
      month: "",
      exportRemarks: "",
      searchForm: {
        // 搜索框初始化对象
        orderNo: "",
        pageNumber: 1, // 当前页数
        pageSize: 10, // 页面大小
        startDate: "",
        endDate: "",
        userType: "1",
      },
      selectList: [], // 多选数据
      date: [],
      exportData: [],
      shipperColumns: [
        // 表头
        {
          type: "selection",
          width: 60,
          align: "center",
        },
        {
          title: "#",
          type: "index",
          width: 60,
        },
        {
          title: "托运单号",
          key: "orderNo",
          minWidth: 190,
        },
        {
          title: "原始单号",
          key: "goodNo",
          minWidth: 190,
        },
        {
          title: "被评价人",
          key: "praise",
          minWidth: 220,
          render: (h, params) => {
            return h("div", [
              h(
                "a",
                {
                  on: {
                    click: () => {
                      this.LookCargoOwnerInfo(params.row.did);
                    },
                  },
                },
                params.row.dname
              ),
            ]);
          },
        },
        {
          title: "评价人",
          key: "loadingUnloading",
          minWidth: 240,
           render: (h, params) => {
            let names = "";
            let text = "";
            let ownerText = "";

            if (params.row.carrierType == 2) {
              // re = "个体户";
              names = params.row.ename;
            } else {
              // re = "车主";
              names = params.row.affiliatedCompanyName;
              ownerText = params.row.affiliatedCompanyName + " (" + params.row.ename + ")";
            }
            if (names.length > 8) {
              let text1 = names.substring(0, 4);
              let text2 = names.substring(names.length - 5);
              text = `${text1}...${text2}`;
            }
            if (ownerText) {
              names = ownerText;
              text = text + "(" + params.row.ename + ")";
            }
            return h(
              "Tooltip",
              {
                props: {
                  placement: "top",
                  maxWidth: "220",
                  content: names,
                  transfer: true,
                },
              },
              [
                h(
                  "a",
                  {
                    props: {
                      type: "primary",
                      size: "small",
                    },
                    on: {
                      click: () => {
                        if (params.row.carrierType == 2) {
                          // re = "个体户";
                          this.individualBusinessOpen(params.row.eid);
                        } else {
                          // re = "车主";
                          this.newOwnerDetailsOpen(params.row.eid);
                        }
                      },
                    },
                  },
                  text
                ),
              ]
            );
          },

        },

        {
          title: "好装好卸",
          key: "loadingUnloading",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.loadingUnloading >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.loadingUnloading.toFixed(1)), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            }
          },
        },
        {
          title: "结算及时",
          key: "settlement",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.settlement >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.settlement.toFixed(1)), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            }
          },
        },
        {
          title: "货源靠谱",
          key: "sourceGoods",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.sourceGoods >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.sourceGoods.toFixed(1)), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            }
          },
        },
        {
          title: "交通便利",
          key: "traffic",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.traffic >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.traffic.toFixed(1)), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            }
          },
        },

        {
          title: "评价时间",
          key: "createTime",
          minWidth: 170,
          sortable: false,
        },
        // {
        //   title: "操作",
        //   key: "action",
        //   fixed: "right",
        //   width: 90,
        //   render: (h, params) => {
        //     return h("div", [
        //       h(
        //         "a",
        //         {
        //           on: {
        //             click: () => {
        //               this.settlementModals = true;
        //               this.dataPict = params.row;
        //             },
        //           },
        //         },
        //         "查看"
        //       ),
        //     ]);
        //   },
        // },
      ],
      actualColumns: [
        // 表头
        {
          type: "selection",
          width: 60,
          align: "center",
        },
        {
          title: "#",
          type: "index",
          width: 60,
        },
        {
          title: "托运单号",
          key: "orderNo",
          minWidth: 190,
        },
        {
          title: "原始单号",
          key: "goodNo",
          minWidth: 190,
        },
        {
          title: "被评价人",
          key: "praise",
          minWidth: 240,
             render: (h, params) => {
            let names = "";
            let text = "";
            let ownerText = "";

            if (params.row.carrierType == 2) {
              // re = "个体户";
              names = params.row.ename;
            } else {
              // re = "车主";
              names = params.row.affiliatedCompanyName;
              ownerText = params.row.affiliatedCompanyName + " (" + params.row.ename + ")";
            }
            if (names.length > 8) {
              let text1 = names.substring(0, 4);
              let text2 = names.substring(names.length - 5);
              text = `${text1}...${text2}`;
            }
            if (ownerText) {
              names = ownerText;
              text = text + "(" + params.row.ename  + ")";
            }
            return h(
              "Tooltip",
              {
                props: {
                  placement: "top",
                  maxWidth: "220",
                  content: names,
                  transfer: true,
                },
              },
              [
                h(
                  "a",
                  {
                    props: {
                      type: "primary",
                      size: "small",
                    },
                    on: {
                      click: () => {
                        if (params.row.carrierType == 2) {
                          // re = "个体户";
                          this.individualBusinessOpen(params.row.did);
                        } else {
                          // re = "车主";
                          this.newOwnerDetailsOpen(params.row.did);
                        }
                      },
                    },
                  },
                  text
                ),
              ]
            );
          },

        },
        {
          title: "评价人",
          key: "loadingUnloading",
          minWidth: 220,
          render: (h, params) => {
            return h("div", [
              h(
                "a",
                {
                  on: {
                    click: () => {
                      this.LookCargoOwnerInfo(params.row.eid);
                    },
                  },
                },
                params.row.dname
              ),
            ]);
          },
        },
        {
          title: "运输效率",
          key: "transportEfficiency",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.transportEfficiency >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.transportEfficiency), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            }
          },
        },
        {
          title: "运输安全",
          key: "transportationSafety",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.transportationSafety >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.transportationSafety), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            }
          },
        },
        {
          title: "服务质量",
          key: "serviceQuality",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.serviceQuality >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.serviceQuality), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            }
          },
        },
        {
          title: "客户满意度",
          key: "customerSatisfaction",
          minWidth: 120,
          render: (h, params) => {
            if (params.row.customerSatisfaction >= 1) {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: parseInt(params.row.customerSatisfaction), //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
            } else {
              return h("div", [
                h("Rate", {
                  props: {
                    count: 5,
                    disabled: true,
                    allowHalf: true,
                    value: 0, //
                  },
                  style: {
                    margin: "0px",
                    padding: "0px",
                  },
                }),
              ]);
              // return h(
              //   "div",
              //   {
              //     style: {
              //       color: "#B0C4DE",
              //     },
              //   },
              //   "暂无评分"
              // );
            }
          },
        },

        {
          title: "评价时间",
          key: "createTime",
          minWidth: 170,
          sortable: false,
        },
        // {
        //   title: "操作",
        //   key: "action",
        //   fixed: "right",
        //   width: 90,
        //   render: (h, params) => {
        //     return h("div", [
        //       h(
        //         "a",
        //         {
        //           on: {
        //             click: () => {
        //               this.settlementModal = true;
        //               this.dataPict = params.row;
        //               console.log(params.row.transportEfficiency);
        //             },
        //           },
        //         },
        //         "查看"
        //       ),
        //     ]);
        //   },
        // },
      ],
      data: [], // 表单数据
      pageNumber: 1, // 当前页数
      pageSize: 10, // 页面大小
      total: 0, // 表单数据总数
      settlementModal: false,
      settlementModals: false,
      valueCustomText: 5,
      dataPict: {},
      data: [],

      //// // // // // // // // // // // // // // // // // // //
      shiexportData: [],
      shiperexportModalVisible: false, // 自定义导出显示
      shipexportTitle: "确认导出",
      loadingExport: true, // 导出加载状态\
      shichooseColumns: [],
      shipfilename: "托运人统计",
      shiexportColumns: [
        {
          title: "#",
          key: "serialNumber",
          minWidth: 60,
          sortable: true,
        },
        {
          title: "托运单号",
          key: "orderNo",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "原始单号",
          key: "goodNo",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "被评价人",
          key: "dname",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "评价人",
          key: "ename",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "好装好卸",
          key: "loadingUnloading",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "结算及时",
          key: "settlement",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "货源靠谱",
          key: "sourceGoods",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "交通便利",
          key: "traffic",
          minWidth: 100,
          sortable: true,
        },
      ],
      ////////////////////////////////////////////////////////////////
      selectList: [], // 多选数据
      exportData: [],
      exportModalVisible: false, // 自定义导出显示
      exportTitle: "确认导出",
      filename: "实际承运人统计",
      loadingExport: true, // 导出加载状态\
      chooseColumns: [],
      exportRemarks: "",
      exportColumns: [
        {
          title: "#",
          key: "serialNumber",
          minWidth: 60,
          sortable: true,
        },
        {
          title: "托运单号",
          key: "orderNo",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "原始单号",
          key: "goodNo",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "被评价人",
          key: "dname",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "评价人",
          key: "ename",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "运输效率",
          key: "transportEfficiency",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "运输安全",
          key: "transportationSafety",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "服务质量",
          key: "serviceQuality",
          minWidth: 100,
          sortable: true,
        },
        {
          title: "客户满意度",
          key: "customerSatisfaction",
          minWidth: 100,
          sortable: true,
        },
      ],
    };
  },
  components: {
    OwnerDetails,
    NewOwnerDetails,
  },
  methods: {
    //  搜索时间
    changeDate(val) {
      //改变选择日期
      this.searchForm.startDate = val[0];
      this.searchForm.endDate = val[1];
    },
    init() {
      this.getDataList();
      // 初始化导出列数据
    },
    //货主详细信息
    LookCargoOwnerInfo(row) {
      this.OwnerDetailsId = row;
      this.OwnerDetailsModalue = true;
    },
    // 货主详细信息关闭
    OwnerDetaiEnd(val) {
      this.OwnerDetailsModalue = val;
      this.OwnerDetailsId = "";
    },
    // 驾驶员
    BidderdDiver(row) {
      this.BidderdUserId = row;
      this.driverModalue = true;
    },
    // 驾驶员详情关闭
    DriverDetaEnd(val) {
      this.driverModalue = val;
      this.BidderdUserId = "";
    },

    //车主详情
    newOwnerDetailsOpen(row) {
      this.newOwnerDetails = true;
      this.newOwnerDetailsId = row;
    },
    //车主信息关闭
    newOwnerDetailsEnd(val) {
      this.newOwnerDetails = val;
      this.newOwnerDetailsId = "";
    },
    //
    ConsultingComplaints() {
      this.shiexportData=[]
      this.exportData=[]
      if (this.consulaint == "shipperName") {
        this.searchForm.userType = 1;
      } else {
        this.searchForm.userType = 2;
      }
      this.getDataList();
    },

    changePage(v) {
      this.searchForm.pageNumber = v;
      this.getDataList();
    },
    changePageSize(v) {
      this.searchForm.pageSize = v;
      this.getDataList();
    },
    handleSearch() {
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.getDataList();
    },
    handleReset() {
      // this.$refs.searchForm.resetFields();
      this.searchForm.pageNumber = 1;
      this.searchForm.pageSize = 10;
      this.searchForm.orderNo = "";
      this.date = [];
      this.searchForm.startDate = "";
      this.searchForm.endDate = "";
      delete this.searchForm.queryMonth;
      // 重新加载数据
      this.getDataList();
    },
    getDataList() {
      for (let item in this.searchForm) {
        if (!this.searchForm[item]) {
          delete this.searchForm[item];
        }
      }
      this.loading = true;
      getEvaluatePage(this.searchForm).then((res) => {
        this.loading = false;
        if (res.success) {
          if (res.result != null) {
            this.data = res.result.records;
            this.total = res.result.total;
          } else {
            this.data = [];
          }
          if (this.data.length == 0 && this.searchForm.pageNumber > 1) {
            this.searchForm.pageNumber -= 1;
            this.getDataList();
          }
        }
      });
    },
    shichangeSelect(e) {
      this.shiexportData = e;
      this.shiexportData.forEach((item, index) => {
        item.serialNumber = index + 1;
        // 好装好卸
        if (item.loadingUnloading) {
          let unloading = "★";
          item.unloading = "";
          for (let index = 0; index < item.loadingUnloading; index++) {
            item.unloading += unloading;
          }
        }
        item.loadingUnloading = item.unloading;
        // 结算及时
        if (item.settlement) {
          let tlement = "★";
          item.tlement = "";
          for (let index = 0; index < item.settlement; index++) {
            item.tlement += tlement;
          }
        }
        item.settlement = item.tlement;
        // 货源靠谱
        if (item.sourceGoods) {
          let source = "★";
          item.source = "";
          for (let index = 0; index < item.sourceGoods; index++) {
            item.source += source;
          }
        }
        item.sourceGoods = item.source;
        // 交通便利
        if (item.traffic) {
          let traffics = "★";
          item.traffics = "";
          for (let index = 0; index < item.traffic; index++) {
            item.traffics += traffics;
          }
        }
        item.traffic = item.traffics;
      });
    },
    changeSelect(e) {
      this.exportData = e;
      this.exportData.forEach((item, index) => {
        // 序号
        item.serialNumber = index + 1;
        // 运输效率
        if (item.transportEfficiency) {
          let transport = "★";
          item.transport = "";
          for (let index = 0; index < item.transportEfficiency; index++) {
            item.transport += transport;
          }
        }
        item.transportEfficiency = item.transport;
        // 运输安全
        if (item.transportationSafety) {
          let safety = "★";
          item.safety = "";
          for (let index = 0; index < item.transportationSafety; index++) {
            item.safety += safety;
          }
        }
        item.transportationSafety = item.safety;

        // 服务质量
        if (item.serviceQuality) {
          let quality = "★";
          item.quality = "";
          for (let index = 0; index < item.serviceQuality; index++) {
            item.quality += quality;
          }
        }
        item.serviceQuality = item.quality;
        // 客户满意度
        if (item.customerSatisfaction) {
          let satisfaction = "★";
          item.satisfaction = "";
          for (let index = 0; index < item.customerSatisfaction; index++) {
            item.satisfaction += satisfaction;
          }
        }
        item.customerSatisfaction = item.satisfaction;
      });
    },

    exportSelectData() {
      if (this.consulaint == "shipperName") {
        if (this.shiexportData.length <= 0) {
          this.$Message.warning("您还未选择要导出的数据");
          return;
        }
        this.exportType = "part";
        this.shiperexportModalVisible = true;
        this.exportTitle = "确认导出 " + this.shiexportData.length + " 条数据";
        this.exportRemarks = "";
      } else {
        if (this.exportData.length <= 0) {
          this.$Message.warning("您还未选择要导出的数据");
          return;
        }
        this.exportType = "part";
        this.exportModalVisible = true;
        this.exportTitle = "确认导出 " + this.exportData.length + " 条数据";
        this.exportRemarks = "";
      }
    },
    shiexportCustomData() {
      // 上传记录
      let param = new FormData(); // 创建form对象
      // param.append("file", a); // 通过append向form对象添加数据
      param.append("fileName", this.filename); // 添加form表单中其他数据
      param.append("fileType", 8); // 通过append向form对象添加数据
      param.append("remarks", this.exportRemarks); // 添加form表单中其他数据
      addDownloadRecord(param).then((res) => {
        if (res.code == 200) {
          // 判断勾选导出列
          let array = [];
          this.shiexportColumns.forEach((e) => {
            this.shichooseColumns.forEach((c) => {
              if (e.title == c && !e.disabled) {
                array.push(e);
              }
            });
          });
          let filename = res.result + " " + this.filename;
          this.shiexportColumns = array;
          this.shiperexportModalVisible = false;
          let title = [];
          let key = [];
          this.shiexportColumns.forEach((e) => {
            title.push(e.title);
            key.push(e.key);
          });
          const params = {
            title: title,
            key: key,
            data: this.shiexportData,
            autoWidth: true,
            filename: filename,
          };
          excel.export_array_to_excel(params);
        } else {
          return this.$Message.error(res.message);
        }
      });
    },

    exportCustomData() {
      // 上传记录
      let param = new FormData(); // 创建form对象
      // param.append("file", a); // 通过append向form对象添加数据
      param.append("fileName", this.filename); // 添加form表单中其他数据
      param.append("fileType", 8); // 通过append向form对象添加数据
      param.append("remarks", this.exportRemarks); // 添加form表单中其他数据
      addDownloadRecord(param).then((res) => {
        if (res.code == 200) {
          // 判断勾选导出列
          let array = [];
          this.exportColumns.forEach((e) => {
            this.chooseColumns.forEach((c) => {
              if (e.title == c && !e.disabled) {
                array.push(e);
              }
            });
          });
          let filename = res.result + " " + this.filename;
          this.exportColumns = array;
          this.exportModalVisible = false;
          let title = [];
          let key = [];
          this.exportColumns.forEach((e) => {
            title.push(e.title);
            key.push(e.key);
          });
          const params = {
            title: title,
            key: key,
            data: this.exportData,
            autoWidth: true,
            filename: filename,
          };
          excel.export_array_to_excel(params);
        } else {
          return this.$Message.error(res.message);
        }
      });
    },
  },
  mounted() {
    this.init();
    // 初始化导出列数据
    let arrays = [];
    this.shiexportColumns.forEach((e) => {
      // 指定列限制权限
      if (!this.getStore("roles").includes("ROLE_ADMIN") && e.key == "mobile") {
        e.title = "[无权导出] " + e.title;
        e.disabled = true;
      } else {
        e.disabled = false;
      }
      arrays.push(e.title);
    });
    this.shichooseColumns = arrays;
    // 初始化导出列数据
    let array = [];
    this.exportColumns.forEach((e) => {
      // 指定列限制权限
      if (!this.getStore("roles").includes("ROLE_ADMIN") && e.key == "mobile") {
        e.title = "[无权导出] " + e.title;
        e.disabled = true;
      } else {
        e.disabled = false;
      }
      array.push(e.title);
    });
    this.chooseColumns = array;
  },
};
</script>
<style lang="less">
.ivu-rate-star {
  width: 8px;
  height: 8px;
}
.box {
  width: 300px;
}
</style>